package com.tinyseed.emcp.api.basicdata.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.tinyseed.emcp.api.basicdata.domain.convert.DTOConvert;
import com.tinyseed.emcp.api.basicdata.model.IndustryOutputDTO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;

/**
 * tb_industry
 *
 * @author tinyCode
 * @date 2019-11-20 17:28:42
 */
@Data
@Table(name = "tb_industry")
@Entity()
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler"})
public class Industry implements Serializable {

    /**
     * 唯一主键
     */
    @Id
    @GeneratedValue
    private Long id;
    /**
     * 行业CODE
     */
    @Column(nullable = true)
    private String industryCode;
    /**
     * 行业名称
     */
    @Column(nullable = true)
    private String industryName;
    /**
     * 备注
     */
    private String remark;
    /**
     * 创建时间
     */
    private Timestamp createTime;
    /**
     * 最后修改时间
     */
    private Timestamp modifyTime;
    /**
     * 创建人
     */
    private String creator;
    /**
     * 最后操作人
     */
    private String modifier;

    public IndustryOutputDTO convertToIndustryOutputDTO() {
        IndustryOutputDTOConvert convert = new IndustryOutputDTOConvert();
        return convert.convert(this);
    }

    private static class IndustryOutputDTOConvert implements DTOConvert<Industry, IndustryOutputDTO> {

        @Override
        public IndustryOutputDTO convert(Industry industry) {
            IndustryOutputDTO industryOutputDTO = new IndustryOutputDTO();
            BeanUtils.copyProperties(industry, industryOutputDTO);
            return industryOutputDTO;
        }
    }
}
